package com.banciyuan.bcywebview.biz.goods.order;


import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.banciyuan.bcywebview.R;
import com.banciyuan.bcywebview.biz.goods.address.ReceiverAddressActivity;
import com.banciyuan.bcywebview.biz.goods.order.confirmorder.ConfirmOrderActivity;

public class OrderAddressViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
    public View viewOrderAddress;
    public View viewAddOrderAddress;
    public TextView tvReceiverPhone;
    public TextView tvReceiverName;
    public TextView tvReceiverAddress;
    private Context mContext;
    public LinearLayout springWarn;

    public OrderAddressViewHolder(View itemView, Context context) {
        super(itemView);
        mContext = context;
        viewOrderAddress = itemView.findViewById(R.id.view_orderaddress);
        viewAddOrderAddress = itemView.findViewById(R.id.view_add_orderaddress);
        tvReceiverPhone = (TextView) viewOrderAddress.findViewById(R.id.tv_receiver_phone);
        tvReceiverName = (TextView) viewOrderAddress.findViewById(R.id.tv_receiver_name);
        tvReceiverAddress = (TextView) viewOrderAddress.findViewById(R.id.tv_receiver_address);
        springWarn = (LinearLayout) itemView.findViewById(R.id.spring_warn);
        initAction();
    }

    private void initAction() {
        viewOrderAddress.setOnClickListener(this);
        viewAddOrderAddress.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.view_orderaddress:
            case R.id.view_add_orderaddress:
                gotoReceiverAddress();
                break;
        }
    }

    private void gotoReceiverAddress() {
        Intent intent = new Intent(mContext, ReceiverAddressActivity.class);
        ((Activity) mContext).startActivityForResult(intent, ConfirmOrderActivity.GOADD_ADDRESS);
    }
}
